<template>
    <div>
    <el-card style="height: 1320px;">
      <div class="title">
        平台介绍：
      </div>
      <quill-editor v-model="content" ref="myQuillEditor" style="height: 500px;" :options="editorOption">
        <!-- 自定义toolar -->
        <div id="toolbar" slot="toolbar">
          <!-- Add a bold button -->
          <button class="ql-bold" title="加粗">Bold</button>
          <button class="ql-italic" title="斜体">Italic</button>
          <button class="ql-underline" title="下划线">underline</button>
          <button class="ql-strike" title="删除线">strike</button>
          <button class="ql-blockquote" title="引用"></button>
          <button class="ql-code-block" title="代码"></button>
          <button class="ql-header" value="1" title="标题1"></button>
          <button class="ql-header" value="2" title="标题2"></button>
          <!--Add list -->
          <button class="ql-list" value="ordered" title="有序列表"></button>
          <button class="ql-list" value="bullet" title="无序列表"></button>
          <!-- Add font size dropdown -->
          <select class="ql-header" title="段落格式">
            <option selected>段落</option>
            <option value="1">标题1</option>
            <option value="2">标题2</option>
            <option value="3">标题3</option>
            <option value="4">标题4</option>
            <option value="5">标题5</option>
            <option value="6">标题6</option>
          </select>
          <select class="ql-size" title="字体大小">
            <option value="10px">10px</option>
            <option value="12px">12px</option>
            <option value="14px">14px</option>
            <option value="16px" selected>16px</option>
            <option value="18px">18px</option>
            <option value="20px">20px</option>
          </select>
          <select class="ql-font" title="字体">
            <option value="SimSun">宋体</option>
            <option value="SimHei">黑体</option>
            <option value="Microsoft-YaHei">微软雅黑</option>
            <option value="KaiTi">楷体</option>
            <option value="FangSong">仿宋</option>
            <option value="Arial">Arial</option>
          </select>
          <!-- Add subscript and superscript buttons -->
          <select class="ql-color" value="color" title="字体颜色"></select>
          <select class="ql-background" value="background" title="背景颜色"></select>
          <select class="ql-align" value="align" title="对齐"></select>
          <button class="ql-clean" title="还原"></button>
          <!-- You can also add your own -->
        </div>
      </quill-editor>
      <div class="pad_top">
        <div class="title">
          公信力证明：
        </div>
        <quill-editor v-model="contents" ref="myQuillEditors" style="height: 500px;" :options="editorOptions">
          <!-- 自定义toolar -->
          <div id="toolbars" slot="toolbar">
            <!-- Add a bold button -->
            <button class="ql-bold" title="加粗">Bold</button>
            <button class="ql-italic" title="斜体">Italic</button>
            <button class="ql-underline" title="下划线">underline</button>
            <button class="ql-strike" title="删除线">strike</button>
            <button class="ql-blockquote" title="引用"></button>
            <button class="ql-code-block" title="代码"></button>
            <button class="ql-header" value="1" title="标题1"></button>
            <button class="ql-header" value="2" title="标题2"></button>
            <!--Add list -->
            <button class="ql-list" value="ordered" title="有序列表"></button>
            <button class="ql-list" value="bullet" title="无序列表"></button>
            <!-- Add font size dropdown -->
            <select class="ql-header" title="段落格式">
              <option selected>段落</option>
              <option value="1">标题1</option>
              <option value="2">标题2</option>
              <option value="3">标题3</option>
              <option value="4">标题4</option>
              <option value="5">标题5</option>
              <option value="6">标题6</option>
            </select>
            <select class="ql-size" title="字体大小">
              <option value="10px">10px</option>
              <option value="12px">12px</option>
              <option value="14px">14px</option>
              <option value="16px" selected>16px</option>
              <option value="18px">18px</option>
              <option value="20px">20px</option>
            </select>
            <select class="ql-font" title="字体">
              <option value="SimSun">宋体</option>
              <option value="SimHei">黑体</option>
              <option value="Microsoft-YaHei">微软雅黑</option>
              <option value="KaiTi">楷体</option>
              <option value="FangSong">仿宋</option>
              <option value="Arial">Arial</option>
            </select>
            <!-- Add subscript and superscript buttons -->
            <select class="ql-color" value="color" title="字体颜色"></select>
            <select class="ql-background" value="background" title="背景颜色"></select>
            <select class="ql-align" value="align" title="对齐"></select>
            <button class="ql-clean" title="还原"></button>
            <!-- You can also add your own -->
          </div>
        </quill-editor>
      </div>
      <div class="btn_center">
        <el-button type="primary" class="mar-top" @click="submit">提交</el-button>
      </div>
      
    </el-card>
  </div>
</template>

<script>
import { aboutUs, aboutUpdate } from "@/api/system/user";
import { MessageBox } from "element-ui";
import {
    Quill,
    quillEditor
  } from 'vue-quill-editor'
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css';
import 'quill/dist/quill.bubble.css';
//引入font.css 
import '../../../assets/font/font.css'
// 自定义字体大小
  let Size = Quill.import('attributors/style/size')
  Size.whitelist = ['10px', '12px', '14px', '16px', '18px', '20px']
  Quill.register(Size, true)

  // 自定义字体类型
  var fonts = ['SimSun', 'SimHei', 'Microsoft-YaHei', 'KaiTi', 'FangSong', 'Arial', 'Times-New-Roman', 'sans-serif',
    '宋体', '黑体'
  ]
  var Font = Quill.import('formats/font')
  Font.whitelist = fonts
  Quill.register(Font, true)

export default {
  components: {
    quillEditor
  },
  data() {
    return {
      list: [],
      listLoading: false,
      total: 0,
      limit: 10,
      curPage: 0,
      content: null,
      contents: null,
      editorOption: {
        placeholder: "请输入",
        // theme: "snow", // or 'bubble' 
        modules: {
          toolbar: {
            container: '#toolbar'
          }
        }
      },
      editorOptions: {
        placeholder: "请输入",
        // theme: "snow", // or 'bubble' 
        modules: {
          toolbar: {
            container: '#toolbars'
          }
        }
      },
      id: '',
    };
  },
  created() {

  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      this.getList()
    },
    getList() {
      aboutUs().then(res => {
        if (res.code == '200') {
          this.id = res.rows[0].id
          this.content = res.rows[0].platformIntroduction
          this.contents = res.rows[0].certify
        } else {
          this.$message({ message: res.msg, type: "error" });
        }
      });
    },
    handleSizeChange(val) {
      this.limit = val;
      this.getList(1);
    },
    submit() {
      let params = {
        platformIntroduction: this.$refs.myQuillEditor.value,
        certify: this.$refs.myQuillEditors.value,
        id: this.id
      }
      aboutUpdate(params).then(res => {
        if (res.code == '200') {
          this.$message({ message: res.msg, type: "success" });
        } else {
          this.$message({ message: res.msg, type: "error" });
        }
      });
    }
  }
};
</script>
<style scoped>
.form {
  padding-left: 26px;
  padding-right: 24px;
  padding-top: 24px;
  background: #fff;
}
.search {
  display: flex;
  position: relative;
}
.search1 {
  display: flex;
}
.search_info {
  width: 120px;
  height: 40px;
  margin-right: 16px;
}
.search_info1 {
  width: 200px;
  height: 40px;
  margin-right: 16px;
}
.search_info2 {
  width: 140px;
  height: 40px;
  margin-right: 16px;
}
.searchBtn {
  margin-left: 16px;
  height: 36px;
}
.sortStyle {
  height: 19px;
  float: right;
  /* right: 24px; */
  margin-top: 20px;
  margin-bottom: 30px;
}
.pos_right_btn {
  position: absolute;
  right: 0;
}
.opt_font {
  cursor: pointer;
  color: #2e82ff;
}
.detail_title {
  font-size: 16px;
  font-weight: 400;
  color: #212121;
  line-height: 22px;
}
.detail_title span {
  padding-left: 4px;
  background: #1e88e5;
  margin-right: 12px;
}
.row {
  display: flex;
  /* padding-bottom: 12px; */
}
.detail_info {
  padding-top: 16px;
}
.info_left {
  display: flex;
}
.info_right {
  display: flex;
  /* padding-left: 202px; */
}
.info_left_title {
  font-size: 14px;
  font-weight: 400;
  color: #616161;
  line-height: 20px;
  width: 256px;
  /* margin-right: 16px; */
  text-align: center;
  min-height: 47px;
  background: #f5f7fa;
  box-shadow: inset 0 -1px 0 0 #dcdfe6;
}
.info_left_title .font {
  position: relative;
  top: 14px;
}
.info_left_content {
  font-size: 14px;
  font-weight: 400;
  color: #212121;
  line-height: 20px;
  width: 256px;
  /* border: 1px solid #DCDFE6; */
  box-shadow: inset -1px -1px 0 0 #dcdfe6;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  /* position: relative;
    top: 10px; */
}
.info_left_contents {
  font-size: 14px;
  font-weight: 400;
  color: #212121;
  line-height: 20px;
  width: 769px;
  /* border: 1px solid #DCDFE6; */
  box-shadow: inset -1px -1px 0 0 #dcdfe6;
  text-align: left;
}
.pos_top {
  padding-top: 12px;
}
.top_more {
  margin-top: 8px;
}
.detailTable {
  margin-top: 16px;
}
.opt_font {
  color: #1e88e5;
  cursor: pointer;
}
.page_pos {
  text-align: right;
  padding-top: 10px;
}
.backBtn {
  text-align: center;
  margin-top: 10px;
}
/deep/ .el-dialog {
  display: flex;
  flex-direction: column;
  margin: 0 !important;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-height: calc(100% -30px);
  /* max-width: ; */
}
/deep/ .el-dialog .el-dialog__body {
  flex: 1;
  height: 600px;
  overflow-y: auto;
  padding-top: 0;
}
.tab {
  display: flex;
  position: absolute;
  right: 55px;
  top: 14px;
}
.tab_border {
  border: 1px solid #409eff;
  color: #409eff;
  padding: 10px 12px;
  font-size: 14px;
  margin-right: 16px;
}
.change {
  border: 1px solid #f56c6c;
  color: #f56c6c;
}
.listTable {
  margin-top: 17px;
}
/deep/ .search_info .el-input__inner {
  width: 120px;
}
/deep/ .search_info1 .el-input__inner {
  width: 200px;
}
/deep/ .search_info2 .el-input__inner {
  width: 140px;
}
.date_picker /deep/ .el-input__inner {
  width: 240px;
}
.opt_table {
  display: flex;
  justify-content: space-around;
}
.footer {
  display: flex;
  justify-content: space-between;
}
.footer_btn {
  position: relative;
  top: 20px;
}
.opt_disable {
  color: #909399;
}
.myQuillEditor {
  margin-top: 26px;
  width: 1200px;
}
/deep/ .ql-editor {
  height: 500px;
}
.about {
  margin-left: 26px;
}
.title {
  padding-bottom: 20px;
}
.pad_top {
  margin-top: 60px;
}
.mar-top {
  margin-top: 70px;
}
.btn_center {
  display: flex;
  justify-content: center;
}
</style>
